/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "company_economic_type")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CompanyEconomicType.findAll", query = "SELECT c FROM CompanyEconomicType c"),
    @NamedQuery(name = "CompanyEconomicType.findByIdCompanyEconomicType", query = "SELECT c FROM CompanyEconomicType c WHERE c.idCompanyEconomicType = :idCompanyEconomicType"),
    @NamedQuery(name = "CompanyEconomicType.findByDescription", query = "SELECT c FROM CompanyEconomicType c WHERE c.description = :description")})
public class CompanyEconomicType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_COMPANY_ECONOMIC_TYPE")
    private Integer idCompanyEconomicType;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "DESCRIPTION")
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "companyEconomicType", fetch = FetchType.LAZY)
    private List<Company> companyList;

    public CompanyEconomicType() {
    }

    public CompanyEconomicType(Integer idCompanyEconomicType) {
        this.idCompanyEconomicType = idCompanyEconomicType;
    }

    public CompanyEconomicType(Integer idCompanyEconomicType, String description) {
        this.idCompanyEconomicType = idCompanyEconomicType;
        this.description = description;
    }

    public Integer getIdCompanyEconomicType() {
        return idCompanyEconomicType;
    }

    public void setIdCompanyEconomicType(Integer idCompanyEconomicType) {
        this.idCompanyEconomicType = idCompanyEconomicType;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public List<Company> getCompanyList() {
        return companyList;
    }

    public void setCompanyList(List<Company> companyList) {
        this.companyList = companyList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCompanyEconomicType != null ? idCompanyEconomicType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CompanyEconomicType)) {
            return false;
        }
        CompanyEconomicType other = (CompanyEconomicType) object;
        if ((this.idCompanyEconomicType == null && other.idCompanyEconomicType != null) || (this.idCompanyEconomicType != null && !this.idCompanyEconomicType.equals(other.idCompanyEconomicType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CompanyEconomicType[ idCompanyEconomicType=" + idCompanyEconomicType + " ]";
    }
    
}
